package com.zr.bookcorner.adapter;

import android.view.View;
import android.widget.ImageView;

import com.zh.baselibrary.base.BaseRecyclerAdapter;
import com.zh.baselibrary.utils.BitmapHelp;
import com.zh.model.manager.BookInfo;
import com.zr.bookcorner.R;

import java.util.List;

public class BookManagerAdapter extends BaseRecyclerAdapter<BookInfo> {
    public BookManagerAdapter(List<BookInfo> mData) {
        super(mData);
    }

    @Override
    protected int getLayoutId(int viewType) {
        return R.layout.item_book;
    }

    @Override
    protected void bindData(BaseViewHolder holder, int position, BookInfo info) {
        BitmapHelp.display((ImageView) holder.getView(R.id.iv_url), info.getImageUrl(), false, R.mipmap.cover);
        setItemText(holder.getView(R.id.tv_book_name),info.getBookName());
        if(info.getStatus() ==1)
            holder.getView(R.id.iv_statu).setVisibility(View.GONE);
        else {
            holder.getView(R.id.iv_statu).setVisibility(View.VISIBLE);
            if (info.getStatus() == 0||info.getStatus() == 9)
                ((ImageView)holder.getView(R.id.iv_statu)).setImageDrawable(mContext.getResources().getDrawable(R.mipmap.status_on));
             else if (info.getStatus() == 2)
                ((ImageView)holder.getView(R.id.iv_statu)).setImageDrawable(mContext.getResources().getDrawable(R.mipmap.status_off));
             else if (info.getStatus() == 5)
                ((ImageView) holder.getView(R.id.iv_statu)).setImageDrawable(mContext.getResources().getDrawable(R.mipmap.status_return));
             else if (info.getStatus() == 6)
                ((ImageView) holder.getView(R.id.iv_statu)).setImageDrawable(mContext.getResources().getDrawable(R.mipmap.status_return6));
        }
    }
}
